Skip to main content

Full text of "VIC Machine Code Monitor"

See other formats


MACHINE 





MC 



CUMUIATOR 



1 



r^^ 



w 



w«t 



H-J^ 




6502 Assembl/la 

Monitor. Features 




re. 



f 




The information in this manual has been 
reviewed ar>d is believed to be entirely reliable. 
No responsibility, however, is assumed for 
iiQccuracies. The material in this manual isiar 
infofnoNon purposes only< ond is subjedto 
chongc without notice, 

c^ 1982 COMMODORE INTERNATIONAI. 

All rights reserved. No pari of this progrom or 
OCCOrn ponying in&trijctior leaflet may fee 

duplicofed, copied, ironsrriiited or reproduced 

in Qfiy form or by any means without ihe prior 
written permission of Commodore Home 
Computer Division. 

Commoders Home Coinputer Division 

675Ajax Avenue, Slough Troding Estate, 
Slough, fterks. SL) 4BG Enalond. 

Printed in England 



MACHINE CODE MONITOR 
(VICMON) USER MANUAL 

TABLE OF CONTENTS 



'^^ 



K I ^ P h 1 



^ 1 ■ I- I 



h 4 I fr I # p H I 



h I ■ k I 



hi' h t 4 I h 4 h V I 



Section One — Introduction to VICMON 

1-1 hfrodudfon ... , 

^ .2 The VICMON Marual 

1 .3 VICMON Functiors , . . . , 

1.4 Stalling Ihe VICMON System , 

1 .5 Ccmn>and Formcrt , , 

1 .6 Enterlrg Conrnnords 2 

1-7 Error Indication .....,..,..._.........,,,...........,...,......_,..,...,,...,,,< 2 

Section Two — The Commands of VICMON 



2_1 

2.2 

2,3 

2.3 

2.3 

2.3. 

2.3. 

2.3. 

2.3. 

2.3. 

2.3. 

2;3. 

2.3. 

2^3. 

2.3. 

2.3. 

2,3. 

Z3. 

2.3. 

2.3. 

2.3, 

2.3. 



I 4h il Hi hh l^hvhqhKlq ^hHi^l- hhHhhiF hh^h 



h I 



h 4 



h 4 



F 4 



1 

2 
3 
4 
5 
6 
7 
8 
9 
10 

n 

12 
13 
14 
15 
16 
17 
18 
19 



Intrixluciion 

Conventions 3 

The Com mc nds ,...,.., , , . . , , . . , 3 

A — Assemble . ._ 3 

B — BreokpoinJ _ , , 3 

D — Disassemble 4 

E — Enable Virtual Zoro Page 5 

I ^^ I III JTICIIIUiT 41 IP IIIVIIIPII II 4111^1 P4l1lilt4l*lilP4l 1^41 I|*II4I1|IIIJIJ|I ly V 

G — Go _ 5 

H 

I 

J 

L 

M 

N 

Q 

R 

RB 

S 

T 

W 

X 



Hunt . , 6 

Interpret 6 

7 



— Jump 

— Lood -..- 

— Memory Display 

— Number 



7 

7 

8 

Quick Trace S 

Registers . , , - . . , 9 

Remove Bre<]kpOint 9 

Sove 9 

Transfer 1fl 

Walk Ifl 

Exit 10 Basic 10 



1 



Section Three — Using VICMON as a Debugging Tool 



3.1 

3.2 

3.3 

3,3,1 

3.3.2 

3,4 



introduction ll 

The Example Program , , , , U 

Th6 Program 12 

lnputtir>g the Proarcrri ..,...,... ,..»<.- i ,..,..»<. -1 2 

Locotingthe Fault 12 

Summory , ...,.., , 14 



Index 15 



III 



TABLE OF FIGURES 



Figure 

2-1 

2-2 
2-3 

3-1 
3-2 
3-3 



Title 

An Example Initial VICMON Display 1 

Register Display , 4 

Eisample of Character String Display , , 6 

Display Printable Characters , 7 

An Example of Register Displays , , , 9 

Flowchart of Example Progrom 11 

Resijltof First AttempMo Ron Exanple Progrom , , ,12 

Screen Filled with A's , , 13 



IV 



SECTION ONE 





ODUCi; 





TO VICMON 



1.1 Introduction 

VICMON isfrienkknomaof Jhe}iexadectrnal 
macfiine ccK^e moritc^r designed to eooble ^os^ 
debugging of triochino code programs which 
are residenMna VIC20comp*jter5y5tem. 

Th is manual docs rot sel out to tench mcchine 
codeprogrcnmingontfieVICBetoreottempling 
tousemacbir>ecode on the VIC you should refer 

fo the following; 

MOS 6502 Programming Maruals 

VIC Progrcmrrers' Reference Guide 
VIC Zero Page Memory Mop, 
Useful reading: 

6502 Asseinbly Lcirrguage Progrorrming 
by Leve^f^c^l, 
Tliese are ovoilobfe from nosl COMMODORE 
Corrtpufer dealers. 

VICMON and fe manual areirtoKfed for use 
by peopfe with some programming sxperierce 
nndsoine knowledge of 6503 CBMmochine 
code progrommirtg, but o high level of Gxperli^ 
isnotrequir^. 

1.2 The VICMON Manual 

This manuol is divided Into three parts which 
are outiin^ below. 

SECTION ONE - INTRODUCTION TO 

VICMON 
This section outlines VICMON in generol 
terms. It explains iHe conventions used by this 
monuol when describing the commarKi fornwis, 
How lo Slort ViCMON is oUd included, 

SECTION TWO — THE COMMANDS Of 

VICMON 
hlhissectioii, each VICMON command is 
expioined. its format shown ond an eKomple 
given. ThecomrrKjndsore in alphabeiicol order, 

SECTION THREE - USiNG VICMON ASA 

DEBUGGiNGTOOL 
This section uses anactuol machine longuoge 

Erogrom to show how VICMON can be used to 
Kote faults in ihe program. 

1.3 VICMON Functions 

VICMON ofTe'5 the follcwtng funchons: 

* Disployingchosenoreosofmemory. 

■*■ Changing ct^ltenls of memory locntionB. 

* Moving blocks of memory. 



* Filling selectedblocksof memory- . 

* Searchingmenoryforo pattern, 

* Examining and changing registers. 

* Setting breakpoints. 

* Executing programs with breakpoint control 

* Storing and retrieving data and programs. 
^ Executing programs at three different speed 

options. 

1.4 Starting the VICMON 

System 

The VICMON cartridge mLsl always be 
inserted or removed from the VIC with the power 
o^. The cartridge is inserJed into the expansion 

port wilh the label on ihe cortridge focing up, 
If a VIC 1010 Memory Exponsion Board is in 
Lse^ this should also be turned off. VICMON 
may be used in conjunction with VIC I2T2 
Programmers' Aid and/or VIC 121 1 A Super 
Expander corlridges. However, pleose note thai 
swne cperatiors may conflict if chonging from 
onecarlridge to another. Therefore the VICmay 
have to belumed ofFto affectively make ihe v 
switch. VICMON may also be used with 
expansion RAM in the Memory Expansion Board. 

To start using VICMON type SYS?-^576 or 
SYS6*409fi, ond then press the RETURN key. 
The VIC screen will now display the volues 
currently hskJ In tlie 6502's registers. An example 
is shown in Figure 1 -1 . VICMON is ready to 

accept your commands. . 




FigiirG U] An examp>ie\mt\Q}VlC/V\ON display. 1 



1^ Command Format 

Most VICMON commands ore □ single 
alphabetic chorader followed by the commond 
parameters^ if required. The camrionds orE 
e;(plQin^ in detoii in Sectiori Two. The 
paromelera include itie start oddress or skirf 
and end oddrasseSj op-codas, oporonds, hen. 
volues, etc. The conventions ond limitotions for 
ihem are defined in Section 2,2, 

Command stole menls [exceplforJ) ore 
termincted ond execution ai thsm is initiated by 
pressing Ihe RETURN key. 

A summary of the commands, their fonnats 
and where they ore described is given on the 
back cover of this manual, 

1^ Entering Commends 

Wfiilsttha VtC k opertiting under VlCMON you 
ore prompted with a "/'. To enter o commond 
simply type the command letter(5J and the paro- 
meter[s). If more than oneporameterbreqjired, 
separate them with spoces, commas, colons or 
ony other convenient symbot. The command 
(except for J) is termincited and execuhon Is 
begun when Phe RETURN key Is pressed. 

1.7 Error lndi«ition 

AnyftrroFsyou moke when inpultin^ the 
command 5t<3t?met»ts ore indicated by a question 
mark following the positiorrofthe error. You 
moy re-type or correct ihe commond jsing \he 
standord VJC editing facilities, Press R^URN 
io rniiiote the corrected command- 



i 



SECTION TWO 

THE COMMANDS OF VICMON 



2.1 Introduction 

In Section Two, eoch VICMON commond er 

given '\r\ alphabetical order. The required fonmol 

is shown and the purpose ond function of the 
command ore explained. A simple exomple is 
included v^ich shows the command, o typical 
response when it is used and an ej^planotion of 
the results of SKecuHng tt, 

In Section Three o more detailed GKomple is 
shown using on ochjol machine code program 
which i&lhen "debugged" using VICMON, 

2J2 Conventions 

The parameters in ihe command formats ore 
reprfi^enled as follows: 
(oddr] otwo byte hex address, e.g. 0400 
(dev) a single byte hex device number, e.g. 



(opcode! 
[operond] 



(value 
(data) 



(ret} 
{offeet} 



a valid 6502 assembly mnemonic, 
e.g,LDA 

o valid opercnd for the preceding 
mstruclion. e.g. ^$fll 
o single byte he)( value, e,g, FF 
a string of literal data enclosEid In 
quotes or heic values. Successive Items 
□re aeporaled with commc^- 

p hvO byte hex oddrGss, e.g. 2000 
two byie hex offsei volue, e.g. 3000^ 



2.3 The Commands 

2^1 A— ASSEMBLE 

Formot : A(addr) (opcode) (operandi 

Purpose : Toassemblecodestartingtromo 
specified address. 

The command allows you to inpul cssembi)' 
code lire by line ond have il slored os machine 
code. When Ihe command is entered, the 
appropriate code is written in memofy 
beoinningatthespecifioduddress. The address 
of the next ovtjjlable memory locotion beyorwJ 
thai required by the ^tciFied op code and 

operond is then prompted awoiting input of 
ddditionol code. 

To terminate the A commomd, simply press 
RETURN when ihe new address is prompted, 

If you input an illegal opcode or operand, 
VICMON will plocea quesHon mork after the 



iflegalciuantifyand will return you lo the monitor 
wilh a prompt {-] on a new line, H you fail to 
specify either the op code or operand^ VICMON 
willignorethelineondretymyoutothemonitor 
with a pfompi [-) on a new line, 

NOTE: All operands mtjsf he given os hex 
n\jmber5 preceded by a dofiar sign, i.e. type6<is 

Snn, 

EXAMPLE : To enter the following machine 
code: 

LDA#S19 
JSR $ FFD2 

RTS 

beginning at address $100C, 

COMMAND: A 1 000 LDA #$1 9 [RETURN) 

DISPLAY :.A1000LDA#$19 

.A 1002, 

TYPE 7 JSR $FFD2 (RETURN) 

DISPIAY : _A1000LDA i^$19 

A10(HJSR$FFD2 " 
jM005 

TYPE : RTS (RETURN) 

DISPLAY : .A1000LDA #$T9 
A1002JSR$FFD2 
^1005 RTS 
.A1006 

RESULT ; The n>achine code equivolenr of 
ihe specified assembly longuoge 
code is stored in memory from 
locotion 1000 to 100^ inclusive. 

2^J2 B— BREAKPOINr 

Format ; B [addr) 

or: B(oddr),n 

where n is o four digit HEX 
number Indicating haw mony 
times that address will be 
encountered before the break 
occurs. 

Purpose : To set a breokpoint so that o 

program does not oxeculo fully 
Ixrt instead stops otthe specffied 
lo^iation. 

A breakpoint allows you lo run your program 
uptao specified address. IFyouusedG (see 
Section 2.3,6] lo iniiiote ihe run, the conients of 



flhft registers ore displayed aulomaticdiy, 
dlovWng you todetermir>e if ifiey areas expected. 

The Q mode of execution [see Section 5.3.13] 
will also stopcrtthebreokpoini bill the registers 
will nolbedisployed.YoLjvill be switched to the 
W mode. [See Section 2.3h1 9.) To displcy the 
r^r&t6r&, press Ihe STOP key oncJ ihen use ^^^e R 
commona [See Sectiofi 2.3.14.) 

NotB tfial the run terminates before tfie 

mstruction in »he specified oddress is executed, 

Yov musi be coreKpl not to set o breakpoint 
betvi/eenonopcodeond itsoparandor In the 
midst of data, Doing so will coieeihe break - 
point to be ignored and Ihe resulting run to be 

unpredictable. 

It is possible to exec Lite an oddressa specified 
number of timas and break on the subsequent 
poss, This is done by specifying the numberof 
jlei^ljorts (the n in Ihe formot stotemenl ol^ove), 

If no number Js given ofter the address, the 
progrom will break wtientkit address is 
encountered the first lime_ 

Type \r\ the breakpoint command ar\<^ prew 
the RETURN key. Now run the program using 
the G or Q commond. The program will njn up 
to ihe breakpoint and slop [unless tfie prog ram 
has logicolfouh* which prevent its reaching the 
specified address). 

You con only set ore breakpoint before ychu 

begin running your progrom. When o break- 
poini is raoched you may then set anew breok- 
pointifyou wish. You can resurne the program 
execution oFtera breakpoint using any oF the run 
commands {G,Q,W, J), i.e.yoLiore not restricted 
10 ysirfcQihesame method of running IhroLfghout, 

jfo bref^kpcintisneverreochBd, exec Litkin can 

be stopped by pressing the STOP key ond then 
Ihe RESTORE key. This will return you to BASIC. 
YoLP should re-enterVICMONona set on earlier 
breokpoinitoisololeyOurproblem-ISeeSeciio-n 

Three.] 



EXAMPLE 



COMMAND: 
COMMAND; 
RKULT 



EXAMPLE : 

COMMAND: 
COMMAND: 



Assume ihat you have a program 
in memoryfrom locclion 1665 to 
locotion 1 20P. To stop the 
program execution before 1050; 

Bie>30)RETURN| 

Q1000 [RETURN) 

The program will slowiy execute, 

Stopping before line 1050 is 

executed. You will be left in tho 
WALK mode. 

To set a breakpoint So that ihe 
progfom will stop the third time 
location 1 100 ia reached: 

B110D,0003 [RETURN] 

01050 (RETURN) 



RESULT : The program w[ll run, stopping 

before locohon 1100 is executed 
Ihe third time. The contents of the 
registers ot that point will be 
dispbyed in tlie formal shown in 
Figure 2-1 . 






Ci t^lt^ KR VR 

& 11. e-3 



Fj^gufE2-r Seg/'steJ' Dr'sp/oy 



2^^ D — DfSASSEMBlE 

Format -. Djaddr) 

orrD[addr].(oddr) 

Purpose : To disassemble code from a 
specified point or between a 
nange of points, 

NOTE: forward or bocWord scroUing with the 
cursor mo vemen^teyswf// confinue ta 
dfso ssemb/e coc^e. 

TliG D command enables you lo convert the 
code thai is stored in tiie compuler's mamDry 
back intoassemblylcnguoge notation. You may 
Kpectfy o beginning address in which cose ihal 
lineofcodewillbedisossemWedanddisployed 
in ossen^bly languoge on ihe screen. The VIC 
will remoin in ihe disassemble mode and you 
noy use the cursor to disassemble additional 
lines opcode, i.e. the cjrsar-down key will 
disassemble Ihe line(s] following the specified 
lire and ihe ctirsor-up key will disassemble 
precodlng lines. Note, however, Ihat the dis- 
OSSembly will not begin until the cursor rsachc^s 
the bottom (orlop) of the screen ond^eKrolling 
begins, 

WARNING: Workiryg boctwrrrds v>/iih t^e cursor 
key tnay not giv^ o fieriectfy accurate fyonsiaiioiy 
or tfje code, 

Aftemolively, you may specify a range of 
addresses to be disogsembled. The lines specified 
will bedisplayed on the screen. If you specify a 
range of addresses tfiot is too tang to be 
displayed on the screen q\ one time, ihe screen 
will scroll. The STOP key will terminate the 
5Croilingnnd y<Mi will remain in the disassemble 



mode. Yoy may diaassenAlesub&equenJ lines 
with \\\G cursor-down key. 

W>iileyouareinthedisassemblemode, uljne 
of code on telescreen can be niodified by simply 
correding or refyping the line and pressing 
RETURN- The Acommcrd is aulomoticalty 
Qclivoted. WVct yOu hove made the change, 
ycu remah in the A mode with iha c jr&or 
positioned after tiie address on the line 
following the corrected line. To teminale the 
assemble mo6e, dear ttie screen ond press 
RETURN. 

EXAMPLE : Todisas&pmblethelrnesoFcode 
inpui in the example of the 
cssemble commarKJ and ihen to 
change ihe address in It^e second 
linetoFFOT: 

COMMAND: D 1000, 10C5 (RETURN] 

DISPU^V :.10fflLDA#519 
.1002JSRJFFD2 
.1005 RTS 



ACTION 

TYPE 
DISPLAY 



RESULT 



; Move the cursor so thot it is 
positioned Dverthe2 in ihe FFD2. 

: (RETURN) 

■_10(JflLDA^$19 
,A1002J5R$FFM 
.A1005RTS 

; The code from location 1000 to 
locotior 1005isdi5asMmbled. 
Tbe chonge Is mode and then 
srored with the RETURN key, Ywj 
□re lett ir the ossemble mode. 



use the E corrirnand with Ihe zero page address, 
i.e. E0000. 

EXAMPLE : To set virtual zero page beginning 
ot locution $1000: 

COMMAND; E 1000 [RETURN) 
RESULT :ThelocQlions$1000lo$10FFv-ill 
besetosidsoso virtual zero poge. 



2.3.5 F — FILLMemory 

Format : F{oddr], (oddr), (volijel 

Purpose : To fill memory between twospeci* 

Had addresses v/ilh o given votue. 

The F command enables yOu to pi;t known 
Voll>e inio a specified block o^ memory. This is 
useful for initializing dolo struclures or for 
blanking oul tho contents of ony RAM areo. 
SIrriply specify the range of ihe block of memory 
era the pattern you wish to write irthol block. 
NaturallyyousHould not specify addresses from 
$^{30^ to $01 FF [pages zeroond ane). Similarly, 
if you ore using a virtue I zefO page [s&etheE 
command, Section 2^.4) you should ovoid thot 

■areaoswelL 

EXAMPLE : To write $EA [a rio-op instrLrdion} 
from locotioi $1 000 to $20M 
irclu^ive- 

COMMAND: F 1 000,2«f0,£A (RETURN) 

RESULT : Tlie no-op insimdiori [SEA) i& 
written In all ihe oddressei from 
$100fltoS20eB. 



2^.4 E— ENABIC VJitucil Zero Pago 

Format ; E(oddrJ 

Purpose : Tosetasideavirhfol icropoge 
so tliat VICMON does not 
interfere with your variables. 

VICMON usOT locotior»$ffito$71 of zero 
page. The Kernol uses the rest of the zero poge 
and some of the $200-$900 pages. Since your 
program moy assign variobtes which will be 
stoi^ on Ihe zero page, running the progrom 
moy interfere with some oFthe infonnation 
already stored Ihere. To prevent ihis, ihe E 
command enablasyoutosetosidea virtual zero 

page of 256 bytes at another locotion. When a 
virtual pagp has been sel and your program is 
run. VICMON oulomoficdly swaps the zero 
poge contents with the virtual zero poge 
contents, thus protecting the VICMON ond 
Kernal i n form oti on. When program execution is 
terminoted, ^ey ore swapped ogoin. 

To disable the virtual zero poge when you 
have your program running correctly, simply 



2^6 G-GO 

Formoi : G 

on G(oddr) 

Purpose : To ejtecute a program beginning 

at the locolion currently in Itie 
program counter or beginning 

from o Specified oddrew- 

TheG command maybe used alone or stated 

wrthonQdcJres&.WhenGi5U5edolore,thBVlC 

will execute ihe progrom in memory beginning 

wilh the location currenriy in ihe program 

counter. [To display ihe contents of the program 

counter, use the R commond os described in 

Section 2.3.14.) When an address is given wilh 

the G commorid, execution wnll begin at the 

location specified H 
The Gcommond restores the registers lo their 

lost known states and if a virtual zero poge is 

cctive [see the E command), exchonges 

VICMON's zero page with the virtual zero 

page. Execution of your progrom will continue 

until a preset breakpoint, if onv [seefheB 

command) or until the end of the program is 



reac^ied, unless the pFogrom k]s logical flaws. 
If JHe eMecution is terminaled by a brenkpoinl, 
iKe contents of the registers ot that point will be 
displayed. If ihe program is Jerminoted by RTS, 
when thct command is reached yew will be 
returned to BASIC If the last commorKi is BRK, 
when it is reached you will be relumed to 
VICMON. IfnoteFminaforisottainobladuetoa 
flawintheprogran^^yoLj will have to use Ihe 
STOP and RESTORE Uys to termirwte the 
execution, Yov will friert be in BASIC ond musi 
f^-ente-VICMON. 

NOTE: If yo\/r program hnsch(j^ge<:ifhe screen 
ond/orie^r colours you moy be uitabie to see 
^e RE ADY or fhe register disphy- 

ror ofher means of executing progrorrw, sqb 
the J, Wond Q commands. Sections 2.3.9, 1 B 
QndlSrespecHvely. 

iVOTt: frequent breo/rpofrrfs can prevern The 
progrrom becDmjVig "runaway". 

EXAMPLE : Assume Ihol yoj have a program 
in meinor/ and wish to begin 
execLrtirg it from locoticm $2ftM^ 

COMMAND: G 2Wfl (RETURN) . 

RESULT ; The repr^ters will be restored. The 
PCwjirbesetloS2000.lfavirtuor 
zero page hos been established, 
it will be swopped with the 

VICMONiero page. The 
progromwill begin executing ot 
$2000. 

2.3.7 H— HUNT 

Format ; H (addr), (oddr), {data) 

PurpcMe ; To seorch through □ specific 

block of memory ond locale all 
occurencesof parlicularckila or 
cha rocter str ings. 

The H command easily locotesonyspecifiad 
character pattern Ihat Is in the computer's 
meinory and displays it on the screen. You nioy 
u» Ihis command to locote dola, which isspeci- 
fied in hex, or to find text strings up to 88 
charocler^ long [one Itrw)^ -A^iich are specihed 
literally ar*d preceded by o single quote mork. 
All locations within Ihe specified range which 
contain the requested characters will be found. 
Ihhere are more occurrences Than will fit on the 
screen, the screen wiN scroll. The STOP key wilt 
terminate both ihe scrolling ond Iho HUNT and 
refumyouloVICMON.TTie control key will slow 
down Ihe rale of ihe scroll. When alf occur^ices 
within the range hove been locoied^ you will be 
returned to VICMON. 

EXpWPLE ; Assume that the data siHng 
$A92F3C is stored in m^nory 



somewhere between locatfcin 
$C000 and location $ C0FF. To 
locote the string: 

COMMAND: HC9Oe,C0FF^9,2F,3C 

(RETURf^J 

RESULT : Memory is searched between 

SCW0and$C3FFandthe 
bcolion where $A92F3C is 

slored is displayed.^ 

EXAMPLE : Assumethattheword 

COMMODORE is stored in 
nemcKy in three locations 
belween $2000 ond S3000: 

COMMAND: H2000.3gS0/COMMODOftE 
(RETURN) 

DISPLAY r See Figi/re 2-2. 






' * 1 1^^ -'C^»aJiliii;tl.^J*3^l^f•'^-i 



Fig\jre2-2 Examph of Chorader String D'fsphy. 

2.3.8 I— INTERPRn 

Format ; I (oddrj, [addr] 

or: I [oddr) 

Purpose : To locate and dtsplay printable 
text charocPers within a specific 
block of memory, 

Thelcommand will display in reverse video 
any of Ihe 96 printable CBM ASCII code 
equivolents occuring within the Specified block 
ofmemory. All other charocters in the block will 
be indicoted by o dot (.J, If the specified block 
more than fills the screen, the screen will scrall. 
The STOP key will terminate the scrolling and 
the control key will slow down the rate of 
scrolling. When the specified INTERPRET is 
terminaled, you will remain in the I mode. 
Pressing the cursor-down key will display any 
CBM ASCII choraclers on the next Ihe os the 

ficreenscrolls, t 

EXAMPLE : Assume thai Iha hex codes fo* C 
carriage return, linefeed, CB. 
carriage relum^ linefeed, and 
CBM, Carriage return, line feed 



■J^'^^v^-— ■" 



are sfored beginnrng til IncaHan 
$1000: 

COMWL^ND: I IftM (RETURN) 
DISPLAY ^ See Figure 2-3. 




Figure 2-3 Disphy Printable Chorodefs 



2.3.9 J— JUMP to subroutine. 



Formal 
Purpose 



ti 



: To GKecLrteo subroutine call ond 
return wiihouf single-stepping 
w^iilst running a progrom under 
theWcommorxl. 

The W cooimond runs your prc»grarn one lirte 
olfj time, i,e, after exeajlingaiinejt waits for an 

input from you before proceeding. Whfki In Ibis 

mode, you may v^ish to execute o sub-routine oJJ 
atorce, for example, when you hove already 
checked it by sirgfe alEpping. Vdu mciy wisli to 
move through the sub-routir»e quickly on 
subsequent colls. The J commard enables ycu 
to do this. Simply press the J key when the fine 
containing Ihe subroutine coll is displayed- lii^ 
not necessary to press the RETURN key. Note 
ihotfheJ will notappeciron the screen. 

When the J command is used^ the correct rehim 
oddreiss is pushedon the stock and ttie&ubroirfirw 
IS'flKMuted- When the find RT5 instruction h 
encounteredjlhe program counter will be set to 
the return oddress which was pushed on to the 

sfock. You will agoin be in the WALK mode, 

EXAMPLE : Assume that you are in the WALK 
mode ofkI the following code is 
on the screen; 

147FLDA#$00 
1481JSR$A2C7 
COM>.\AND: J 

RESULT ; $1 484 is pushed on the slock. The 
subroutine be9inning at $A2C7 is 
execuied, When the RTS is 
reoched, the stock is popped ro 
the PC. You ore relumed to W 
mode. 



2^,10 L— LOAD 

Format ; L "FILENAME", (dev) 

Purpose : To load o program file into 

memory from a specified device. 

The L command enobles you to read a load 
filoora program filethotisstoredoncossette or 
on diskette and wriie it into the VIC's RAM. For 

diskfl[B5,theoddressofthefirstlocationinRAW 
into which the load file will be reod must be the 
firslFwobyles of ihe file. Tape files hove the stort 

ocidress as port of the initjol heoder block. 

NOTE: Only progrom files that havs been 
Quoted using the 5 commarKf of ViCMON fsee 
Section 2.3. ]6)otSAVI in ViC BASlCmaybe 
looded with this op*/on. 

The command consisis of L, the nome of the 
file ond the number of the device to read from. 
The ftle name musi be enclosed in quotorion 
marks and may be any legal VIC file name, The 

device r>umbercf (he cassette unit is 01 . The 
device numberofihe disk unit is 0B. 

When the L command is usedj the specified 
"fife on the device will be read into memory until 
an EOF is encouniei^. If the EOF is rot 
encountered, the LOAD will not terminote and 
vou will hove to press the STOPond RESTORE 
keys to stop it. 

if ihe device or file is not present you will get 
an error message and be returned to BASIC. 

EXAMPLE : Assume that you hove □ disk 

program file romed TESTthol is 
258 bytes long, ihe first two bytes 
of which ore 00CA. To reod lhi& 
■file into memory: 

COMMAND: L "TEST", 08 (RETURN) 

RESULT : The progrom named TEST which 
isonthedisketteinthediskunif is 
loaded into memory from CA00 
h>CB00 inclusively. 

2*3.1 1 M— MEMORY 

Formot : M [oddr), (oddr) 

or: M (addr) 

Purpose : To display Ihe hex code that is 

stored in a given block of 
memory. 

The M comriKind will display the contents of 
memory from the beginning oddress in the 
commend uptoond including the corierrts of the 
ending address. The display will hove the 
address and five heK bytes on a line. If only one 
address is given in ihe command, five bytes wr II 
be displayed beginning with ihe conients of ihe 
specified address. 

Additional groups of five bytes maybe 
displpyed bycousing the ^reen lo scroll, i.e. 



using the cursor conlrol keys. NoteJhat iFyou 
spscily Q second address which is smaller than 
me first you will wrap around from ifie end of 
memory to the beginning- 
The contents of memory may be changed by 

lyping over Ihe disployed values and ihefi 

pressing itie RETURN key. If there is a bod RAM 
loctrfionor ifyoualten^pttomodify ROM, a ? 
willbedisplcyeda'thelocaHonoftfieimpgsablB 
charge, 

EJCAMPLE : To display five bytes of memory 
bo9ir>r>ir»g a\ kication $1000 orid 
to change the 00 to FF: 

Ml 000 (RETURN] 

.1000AflQ0EAEAFF 

Position the cursor over the fif^t 
of 00. Type FF cir>d press REPJRK 

: The five bytes of Ihe memory 
beginnirgallocalion $1000 now 
reodAflFFEAEAFF. 



COMMAND 

DISPLAY 
ACnON 

RESULT 



8 



2J3.12 N— NUMBCR 

Formot : N (oddrMaddrUoFffiol), 

(lowlim},(uplim].W 

where offset Js o hex val je mdJ- 
cotrng the ornount to b^ ndded lo 
the exisling addresses and kiwlim 
and uplim spG<:iry the rQr>ge of 
the operandsto be offset and W 
is an optional command indkal- 

ing thai the range i^a word 
toble. 

Purpose : To reassign absolute niomory 
addresses between specified 
rof^o^ w'lon o program has been 
relocated with the T comnwind. 

With the T commond [see Section 2.3,17), you 
con relocate your program lo onother port of 
memory. Of course, [f yourprogrom contnins 
absDJL/to oddre^se^, ihase oddrcsses will no 
longer be valid, The N command ofbws you to 
outorratkally chcinge th^sevolues. First you 

m jst calculate the amount you have moved the 

progrom, Nolethoi if you hove moved ihc 
progrom to c lower memory location, you must 
calculate ihe wrop-n round vqIug^ e.g. if your 
program was at $Afl00 and 's moved to $0430, 
yrxiTiove movod $6400 cilice $A000 + $6400 ^ 
$10400. The votire $iJ00 is the offeet. 

Wiffithe N command you rrwy chorgeoll 
absolute addresses or only those within a specific 
ronpe.The ran^e is esloblished by setfing upper 
ona fower inclusive limits. You must also specify 
the block of rr>emory in whichihecharigeis 
required. VIO^ON will take each operofKl 
within tftt block end odd the omount of the oFfsei 
tort, i.e. [twill overlook three bytes and odd the 



offset to the next two bytes. Of course, if you 
wont to change a word toble, this would be 
disastrous, butVlCMON has provided for this 

withtheoptiorwIWattheendofrtieNcommand- 

Whenthe Wis included, every word, i.e. every 
two byles, will be offset rother^hanosdescribed 
above, 

WARNfNG: Do not use ths N command in ihe 
ronge of your doto locoh'ons aryou wiW c^esfroy 
fhe data's usefulness. 

EXAMPLE : Assume ihot you have used the 
TRANSFER comnnond to relocote 

your program, llwos in locohons 

$1000 to $2000 orKJ rK}w is at 
$l500tD$2500.Toapprupri- 

otely adjust oil the absolute 

addresses in that ronge: 

COMMAND: N 1500,2500,0500.1000,2000 
(RETURN) 

RESULT : Within the code in locations 

$1500toS2500,allobsolute 

addresses l-Kotfoll between 
51000 to $20d0are increased by 
5500. 

2^.13 Q — QUIGKTRACE 

Format : Q 

or; Q (oddr) 

Purpose : To run a program at □ slow pace 

begin ni ng at th e specilied odd ress 
ond checkirig for o breakpoint or 
your u^e of the STOP and X keys 
ofter each instruction is executed. 

The Q comrrKindJike ttie G command [see 
Section 2,3,6), may be used alone or stated with 
an address. When it isusedalone^VICMONv^ll 
execute the program in memory t^innirt^wirh 
the location currently in the program counter, 
[To display Ihe corklents of Ihe program cour>fer. 
use the R command as described in Section 
2.3.14.) When an address is given with ihoQ, 
execuh'on will begin of the location specHied, 

The Q command functions much os the G 
command with one major ejiception. Whilst G 
turns program control completely over lo the 
CPU, Q executes one irstnjction ot o timer 
checkir>g afterecch step to see if o breakpoint is 

set or ff you hove asked for execution to 
terminate. This breakpoint check allows you lo 
set breakpoints in ROM as well as in RAM, 
When Ihe breakpoint is reached, execution will 
stop and you wifl be in the WALK mode. (See 
Section 2.3J S.) To display the? registers of ihis 
point, press STOP, R and RETURN. 

The user interrupt can bt- generated from iho 
keyboard at any point Simply press the STOP 
key and then theX key. Execution will be 



• 



^ j_ 



^^^^^■^^^^i^-^^^^T^^SKr^i^riS:?-.^^ 



x^u^ 



■ciiii=a 



terminated and Hie conlenis of \[\c regisler;^ al 
that point will bedi^pla^-ed. 

EXAMPLE : To execute □ pro^rofri ir QUICK 
TRACE mode beginning cit 

COMMAND: Q 10Cfl ■RH'URN) 

RESULT : The PC is set to 1 000. The 

registers ore initialised. H a 
virtual zero poge (see thtjE com- 
mand, Section 5,3.4^ hos been 
established, it is swopped with 
thezeropoge. Pfogrom execution 
is begun ot fine 100S' 

2A14 R— REGISHRS 

Formot : R 

Purpose : To disploy the tontcjfits ol the 
registers. 

T>ie R conmand enables you to view ths 
Current status ofrhe following registers in the 

VIC 20'fi 6502: 

progjann counter PC 

status register SR 

□ccumufator AC 

index register X XR 

index regisierV YR 

skid: pointer SP 

ThJscar»beu5Btiil whenyou are debugging o 
progTOm because the R enables yo Jto &&s if iho 
registers contain the volues you expected. You 
may olso ckirge the valueas in Ihe registers whilst 
in the R mode by simply typirg over a new vdue 
and pressing RETURN. The register display is 
automoticolTy generated when VICMON is 
started up, ^en a preset breakpairt [see 
Seclion 2,3.2) is reached in the G mode (see 
Section 2.3.6}, and when o Q mn [saa Section 
2.3-13] isterminated by the STOPandX key 

combinollon, 

EXAMPLE ; To display Hie contents of ihe 
registers: 

COMM/a^JD:R [RETURN) 

RESULT : Rgyre2-4,forexcimple, 



;. 3 5E: 






. : :Lia 



tj SR i^C IKR v E 'ili'r' 
&Z Bl F'2 S'i' ^'^ ^ <-■ 









^s 



^uT^2-4 M example oi Register Dlspioys 



2.3.15 RB — REMO^n BREAKPOINT 

Format : RB 

Purpose : Ta remove a breokpoint. 

Breakpoints are set by the B comrrtand [sae 
Section 2-3,2} and con be removed by the RB 
command, Simply specify RB arid the break- 
point which was set will be removed. If no 
Dreakpoints exist when anRB is e:<ecuteci, 
VICMON Will interpret the command us ifir 
werean Rand display ihe registers, 

EXAMPLE : Assumethalabraakpointwossel 
at location $1 050. To rerriove thai 
breakpoint: 

COMMAND: RB 1050;RETURN) 

RESULT : A breakpoint no longer exisis at 

locotion $1 050. . , 

2.3- 16 S-SAVE 

formal : S "fil^onie".[d*fv),[addr|,(addri 

PLfpOSe : Townletheconlentsofospecified 
RAM orea to a particular device. 

The S command enables you to save o 
pragramondiskeBHorcossettesothatifcanbe 

used at a later time. The command consists of 
the name of the file, the number of the device to 
bewriHenPoand the start and endorfdre^s of rhe 
RAMbbck,Ths Tile name mjst be enclosed in 
quotation marJtsandiTJLjsl obey the syntax rules 

for VIC files, i.e. It must begin with an 
alphabetical characJar and be no more ihan 16 

characters long.The device number of the 
cassoHe unit is 01 and of the disk unit, 08. The 
finol oddress in jst be one larger Ihon the 
location of tf^e last byte you wish lo write. 
WARNING: Jf tfie fTnd addisss is not une larger 
than ihe Jocatior* of the /as* byte yoy wish fa 
sove. ttie hsi hyfe v^'tif be fo5t 

tf the specified device is no* present you wiU 
geton erTormesfiogeand be relumed to BASIC. 

NOTE; V/CMON will not sove memory obave 
I7FFF,^e.rftestort address mos^be $0000 or 

greater bvt not iarger than $7FFF arKi the end 
address meSJ be gnsoter than S0000 but no 
Jorger rhan $300^^ ifyoo oftempfto savememoiy 
ootsidethh ronge, onfythe file heoderwr^f be 
saved, f,e, nodota or ptogromvifi! he wnttef^. 

EXAMPLE : Assume that ycHj havea program 
in memory froinlocotionS1000 to 

$10FF. To write that program lo 
the diskette in the disk drive, 
naming Ihot program TEST 1 : 

COMMAND: S"TESTrmi000,nW 

(RETURN) 

RESULT : A filft named TEST 1 wiH be 
written on the diskette. It will 



conJoimhocodelhalwasinRAM 
location il we to$10FFir>clusive- 

2.3-17 T-TRANSrER 

Format ^ T (addrl/addrlXoddrl 

Purpose iTotrarsferthecontentsofo block 
of memory from one oreo oi RAM 
to another. 

TheTcommnnderiablBsyoutorelocQtayour 
progrom or data lo another port of the mertkory. 
Thi^con be useful if you wish (^expand o 
progrom or Id use part of a program flkewhera 
withoul retyping. The command consists of ttiree 
addresses. The firsr two ir>dicatft the blodi oF 

rrMmOry lo be duplkoted. The third address 
indicates the slariittg address for the copy. 
If a program is fronsferred and Ihe program 

contoins obsofiite oddresses or word tables, 
these spMiificotions in the new location will net 
heoccurole. The N command (see Section 
2.3.1 1) allows yojio offset these volues by the 
appropriate omownt so if>otlherelocoted 
program wHf run property, 

EXAMPLE ■ Assume Ihot you hovfi □ block of 
data in mefnory from locoiion 
$3000 to $3500. To move that 
date to a new location beginning 
ot$4000: ^ 

COMMAND: T3^;3500,4m) (RETURN) 

RESULT ; The dcito is now in the bbck 
. . $3000to$35Mandintheblock 
$4000 to $4500, 



tach subroutine must be single-«eppi^d as 
well, unless you we the J command to tre^^t the 
entire sub-roirtine os one slap [see Sedion 2.3.9). 

EXAMfT-E : Tosinglesteplhroughaprogram 
beginning ot locoHon $1000: 

COMMAND: W 1 000 (RETUfeN) 

RESULT : The instrixlion stored otoddress 
$1000isexecurf^and rhenexl 

inslrvctioT is displayed. 
AaiON : Presfi the SPAtt BAR- 
RESULT : Thesecond fnstnjction i^ R>:ecuted 

ond the third mstruchon rs 

displayed, 

2^19 X-£Xrrio BASIC 

Format : X 

Purpose : To term i note VtCMON control 
and return to BASIC. 

UseoftheXcommond returns you lo BASIC, 

Your program will remain \n rnemory butony 
breofepointorvirlual zero page ossignmenis 
will not be preserved. 

EXAMPLE : To eJ<itVlCMON: 

COMMAND; X [RETURN) 

RESU LT : You wi II be returned to BASIC and 

prompted with READY 






10 



2J3AB W— WALK 

Formot : W 

or: W (oddr) 

Purpose ; To execute a program one 
instruction at a ifme. 

The W command Bxecules ihe line of code 
indicated by the address in the program 
counter, if W is used olore. Alternulively you 
moy specify the add^'ess of Ihe irstnjction lo be 

^XflicutMl. 

When using W, ihe firs! insiruction Is executed 
and the second jn^rud^onwrll appeororthe 
screen. VICMON will wait for you to press tfie 
spoce bar before it will onccure the second lir>e. 
When the space bar is pressed, the line will be 
ex^{:uted and rhe nextyne di^play^d. tn this way 
you can WALK, i.e, slngle^step through ^he 
progrom. To retum to VICMON frtHnW,press 
the STOP key. 

You moy use the k commond (see Section 
2,3.14)10 display tbe contents of Ihe registers at 
ony poinL Press STOP, ttien rlie R key and then 
RETUfiN to accomplish this. 



J 
*-*- 



\ 



SECTION THREE 

USING VICMON AS A 
DEBUGGING TOOL 



1.1 Introducrion 

The following is an example which shows 
soine of t^e editing and fault ProcinqfocilJIres of 
VICWON. It u-ie*! a ^502 assembly bngupge 

progrom anti VICMON to show ^K>w on error is 

Icccted in fhs progrom ond fixed. More details 
on the individual commands used here ore 
given in Section Two^ 

If yoLT wish lofryfhe example, follow the 
inslrucllons beginning in Section 3.3. If nol, it is 
suggested that ycMj at leost read th rotjgh Itie 
exompie. 

3^ The Exampte Program 

The progrom used in this secfion writes a 

screen full of each of the printablechoroclers in 

turn. Two screen positrons ore left blank to 
prevenlthe screen ■from scrolling, A flowchart of 
theprogroiTi is shown iri Figure 3-l_ 

The progrom uses ihe ROM rouline $FFD2 to 
print a chorader. FirsI, \he screen is deorcd by 

the following commands: 

IDA #$93 
JSR SFFD2 

Then a loop fills all but the last »wo charocrer 
positions on the screen wrth spaces. There are 
506chQrocter locolrons possible on the screen, 
so 504 have to be filled- This is equivalent to two 
lots of 252 (SFQ. 

Once Ihis has been done, on indirect pointer 
to the screen is sel up in zero page, using the 
contents of $0266 Iq point to the sto rt of ihe 

screen.Twoisoddedtoihisto reference ^e end 

of screen for lestirg. Using o loop, fhe screen 
(gII positions ^lled with spoces) ore filled with 
the first character (value 0\ then tHe second and 

OT on until all 256 characters fiave been in each 

position on the screen where there hod been a 
space. 

ft Is rwcassor^ to print 1o the screen to ensure 
that choroctefs oppeor when they ore stored 
diFCcHy to rhe screen area {STA (S01),Y). Ir is 
possibfe to store values in ihe colour f?AM area 
of memory insteod but this requires ihe u^e of an 
odditionol indirect pointer, 

Thepoge number of the scr^^n is stored in 



(~JT*^_J 



ClI-AW 
SCREEN 



5tK<XJNit-tf 
T025JO 



MISfTA 



TDCOLNTH 




wnVfZMC 
TO CHAR 



SETr^frJTEP 
Tfj ^L"K"!"N 



iPOiNfKl 



INCREMENT 

POIMTER 




F\gure3-1 5Jowc6ortof£jiomp/e Program 11 



locafiDri $0238 which means ifia screen starts ot 
${$0288)00. This niethod is required becaiise if 
ytiu use Gxporsion memory, the Igcotion of the 
screen RAMolters, 



12 



3^ TbePro«dure 

3^.1 INPUniNGTHEPftOORAM 

These are ihe steps to input Ihe program 
described aboveandtoloccrteoTOultin it. Insert 
the VICMON cortridge into tl^e VfC or VIC 
eKponsron board. Switch on the compiler [old 
tht? ^xputiiion boofd if you ore j^ing one). Then 
type SYS (6*'^096:fo:ilartVICMON.Nextu£in9 
the A comniand !y?e Section 2,3.1] type in the 
foil owirg code: 

10MLDA#$93 

1 002 J5R $FFD2 

1M5LDY#$00 

1M7LDX#$00 

lOT9LDArf$20 

100BJSRSFFD2 

100EINX 

100FCPX#^$FC 

1011BNE$1009 

1013INY 

10T4CPY#$02 

ig]6BM!$100? 
1ClBLDXtf$00 

lfllASTX$01 

101CLDA$0288 

101F5TA$02 

1021 CLC 

1022 ADC #S02 
lfl24STA$00 
1026LDYi^$00 
102BTXA 
1029STa;S01),Y 
102B»NY 
102CBNES1029 
102EINC$02 
lfi30LDA$02 
l(i32CMP$00 
1034 BNE $1029 

1037 8NES101C 
1039 6RK 
103ABRK 

Once you hove eriered ttie progrom save it 
on the cossette Lrit (see Section 2^3.1 6) with the 
following command: 

S"PROGRAM",01.10^,103A(RETURN| 

(To5ovQtodiikcMc,iubslilijl*^ SSforfll irthe 
above comiTKird) 
Tliis is o sofegiKird so thotyou do not hove to 



type lh« fM-ogrcm inogoi'r, iFforexomple, 
power to the computer is lost. 

AsBLin i ng that the program wi [l wOrk f i rat \\ me 
(orarfloccurrencewilhnxichine code programs), 
use the GO coTirnond {see Sed-ion 2.3.6) ord 
type: 

G 1000(RETURN) 

If yoj hove typed inlheprogT^mexoctlyos 
Irsteddbovejhekiiphalfoflhe^rL'^jnwilldi^by 
o series of characters very rapidty, The bottom3 
lines of the screen will be blank After ox^ry 
shorl time Jhe program will finish and the screen 
will appearosshownir Figure 3-2. 




pvogrom 



3J^ LOCATING THE FAULT 

Obviously somelhing has gone wrong ond 
you must locale the problem. Here Is a typical 
technique. FirsI, split the program up intolwo 
sections, the first ofwhich will dear rhe screen 
ond fill itwilh spoces. This section ends at$l 018, 
so set a breakpoint [see Section 2,3.2) ol S101 8 
by typing; 

Bl 01 B (RETURN) 
So that you can see what is happen ing, change 

the character printed froniaspi:ice'|$2fl) to an A 

($41). Do this with: 

A1009LDAxj$41 {RETURN) (RPURNJ 

To slowthe operation down, use the quick 
troce Option (see SecHon 2,3.13); 

Q 1000 (RETURN} 

This executes ihe program at a poce much 
slowerthan normoL 

Hyou ore using zero pogs locoticns for your 
program, ilisadvisoble (and usually necessary) 

to make use of the virtual zero page option {see 
Section 2^.4) because VICMON uses the zero 
page and your program and VICMON may 
overwrite each ofher.Thisoption is not required 



*'-^->^>>'*=^'-^'^=-^-^-=^->" 



in this firsi SCdif>n, bul will be required in fhe 
second. 

Since erabling Ihc^irluclzeropags before 
the quick trace is executed will result in taking 
Qpproximolely 2 minures fo clear rhe screen and 
aileasttwicertiotHmelofili it with choraclers 
afterwords, do not enable >r row. 

As Ihe section of code <£] 000'S101 8] executes. 

you will nOtrcG thol rattier than stoppings lines 
shortoftiieend ofthe screen, the charocters 
overflow the srkd of ^e screen. Ihs screen sere lis 
Up (4 lines} crd tfier an e>:tra 2 charociers ore 
priniedThis rnoans thai 4 unwanled characters 
orebeing printed, Themost likely CO jse of ttiis is 
that The lest for ttie number oF^haroclors printed 
is being performed incorrectly. The volue in the 
X register should run botwMn $00 and $FC 
while Y is and Y is 1 . If you look carefully you 
will r>oticettiolonccthc volue of $FCi^ reached 
in)J,ihevolueofYisincrec5ed, lfitislessrtion2, 
a space ("A" Is loaded into the accumulator 

and is printed. This meanstlKitXgo^=:S90'$^f, 
$00-$FC giving the four extra chorocters. To Tix 
Ihisjhe branch at$10l6niij&l be offered ta point 
to SI 007 insteod of J1009. Since quick trace 
leaves you in walk mode, you must press STOP 
Ip return to VICMON. Next, type; 

A 1016 BMIS1W7 (RETURN! (RETURNI 

if you now type: 

Qlffl0 (RETURN) 

the rovtire will stop otlhe correct point on the 
screen arid appear OS In Figure 3-3. 



1^1 riMrif^i^ r=M=%r=^i=ti^ r\f\f^f^ 
ti^ *=i r^ ft « F^ I" * f ^ " 1^ '^ f^ '-T M r:! ^ 

Im r=i Rnn^ PI f ^ ' ■ I".* O ft? ^S^S 
n ' I rtrt rt rt A r=i 1=1 M --» HI ■ > rj -"^ ri 

iJ=ti=iFl R FiR 1^ t^OifM^/^ n fi (^ 

lo n r« R n o n ^ ft f^ iH -=■ " 1^ i=» 1^ 

Irt ri ri r^ 1^ ft /> 1*^ ft *^ r^ rt r-i pH R H 
lripHr-ir^f^r-»rHftft»^H»^ft'-lf-<»l 
iHMf^ftftftftft*^RRROO<> 
1 1^ 9 ©ft ft '^ 1^ ■=" "^ f^ H OO^^ 



'-" * »* 



HR 



0SSI 

^RFll 
f^RFII 



F\gvre3-3 Screen fitted with A's 



Atthis point you car see that the first pariot 
the rouline worfc^fine. Now you should enable 
the virluo! zero page. Press STOP^ ther> type: 

E 1800 [RETURN) 

This will ossign the virtual zero page to o 



blockof memory storting ot location $180fl, 

Now eJieCLrt^ the code tar □ slow rats ^larlirg 

where It finished before, i.e. $1 01 8 os indicated 
fay the PC, The QUICK TRACE mode will allow 

you to go slowly, slopping execution if you r>eed 

to, so type: 

Q (RETURN) 

Ttie A's on tfie screen will start turning inta @"s 
until about half way down the screen [257th 
charorter). The remoining A's will t>e reploced 
by 1^ arrow Symbols, Then ihe ® 's will start 
tumingbocktoA's, However, when the lost® 
chonges, nothing will happen to the screen for a 

shorttimeandthentheA'swill begin turning into 

B's. The left arrow symbols will remain. Note 
thof the screen charocterfor0is@ ,1 isA^2isB, 
etc. 
Press STOP and X together to interrupt the 

program^ because^ asyojcansee,thereisstilE a 
problem, 

Use fheWALK command [set Sodion 2.3.18] 
to single step through the progrom to see if you 
con spot where the wrong chorocler Is conning 

from. Type; 

W 1018 (RETURN] 

After a period of lime (the interval depends 
upon whether you press the SPACE BAR or hold 
itdownjthefollowirgwIllcipoccrronthescrGBn: 

1&102EINC02 
1030 IDA 02 
1032 CMP 0fl 

IC^BNE1029 
1029STA[01),Y 

Atthis pointlheoccumulolorcf^toins the high 
byteoftliescre^n pointer [for the second half of 
tfiescreen].Thisshowsupasa lefiarrowonthe 
screen. If you terminate the WAL< mode [pre«s 
the STOP tey] end display tfie registers by 
typing R (RETURN) (see SecHon 2,3,13], yau will 

■R 

PC SR ACXR YR SP 
102B A0 If 00 00 F2 

The values of PC, SR, YR may vary depending 
on when you pressed the STOP key, i.e. whidi 
instruction is to be performed next. 

At this stage of the progrom^ tfie occumulator 
shouldcontair the some value as theX register. 

As the high byte of the screen pointer is looded 
into the occjmulotor, it Is necessary to transfer 
the voluefromtfieX register into the occumuTafor, 
The instruction for thoiisTXA which is QtSJ028, 
so Ihe branch to $1029 must be changed. Type; 

A 1034 8NE $1026 (RETURN) (RETURN) 
Notethotthe branch atS102C does not need 
to be oltered because the volue of the 
dccunulator is not altered within this inner loop, 



13 



|t:^ 



Rfltnove the breakpcinf^ r^^tore ihe spaces iri 
the injtiol step, and save the program again, by 
typing: 

RB (RETURN) 

A1009LDA#$20 (RETURN) [RETURN] 

S'PROGRAM"^l.lflM,lK3A (RETURN) 

G 1000 [RETURN) 

{^should row work. If It ckies not, compare It 
with tha following program, by Lrsirg the D 
commond to dfsploy the ^\ored code. Spot the 
ditfererKio^ ond made any necessary alterations 
by using ihe A command. Remambefj when 
writing your own programs or ro^/tines yoo 
wo4jldnot havea correct copy of the program Jo 
compore wilh. However, ihe same principles of 
setting breakpornts, executing slowly and 
checking registers applies W any pro^rom, 

,J000LDA#$93 
.,10ef?JSR$FFO2 
.J005LDY#$00 

.. 1009 LDA #520 

.,100BJSR$FFD2 

. , TME INX 

.J00FCPX#SFC^ 

.J0nBNES1009 

.J013INy 

., 1014 CPY #502 

.J016BMf$1007 

_J0iaiDX#$00 

.J01ASTXS01 

, ,101 CLDA 50288 

.,101FSTA$02 

wl021CLC 

-.1K?2ADC#$02 

..1024STA$00 

.J026U5Y#$00 

,,102BTXA 

.,lfl29STA(S01),Y 
.,1C20INY 

. J02CBNES1S2^ 

.,105^rNCS02 

.J030LDAS02 

,J032CMPS00 

,J034BNE$]02S 

,J036INX 

.,1037BNESlfllC 

.,1039BRK 

.,103A??? 



3*4 Summary 

Hare is a sumrrwry of the steps to follow to use 
ViCMON to debi>g your own prcigroms: 

1_ IritiolizeVICMON. 

2. Load your program wilh I 

Or lype it m and SAVE it. 

3. Attempt lo run the program from the start 
cddfe5s using G. 

4. Set breakpoints to determine area of foulr. 

5. Disossemole faulty section [or all of 
program, if it is short) ysing D. It is 
prefefobfe to list the disassembled code on 

your printer. 

6. Quick troce througb Ihe foully section, 
especially if it involves screen disploys, 

7- Walk through ihe foully seclion. 

8, Display registers at vonow points to check 
values, ifnecessary. Use Mondl to display 
areas of dato or working vcriobleSi 

9a. UseAtocorrectfouilycode. 
b. Use Mio correct faulty doto. 

10. Keeporolaofchongesmode.Savelhe 
program frequently. 

11. Remember tfw I you may need to iseviftual 
jero page (E) while you ore using the quick 
trace and walk options. 

1 2. If you connot find the problem, go back to 
your f lo^<^hart[s} and re-think your logic, 



14 



INDEX 



Absolute oddressos 


S 


Addr 


3 


Add ress convent! on 


3 


ASCII, CBM 


4 


ASSEMBLE 


3 


Assembly Language 


i;3Aii 


Back word scrolling 


4 


6ASlC,rRturntc 


AAJ.VO 


. BREAKPOINT 


3AM 


Br^nkpHsint, remove 


9 


BRK 


6 


CBM ASCII 


6 


^ Change absolute oddres&es 


d 


Chonge memory 


& 


Chgngeregisier voltes 


9' 


Com m ond s, ente r i ng 


2 


Commnnds formal 


2 


Comfnond terminal or 


2 


Contro , k^ 


6 


Conventions^ format 


3 


Correcting errors 


2 


Dolo 


3.5/.8 


Debug 


1,3.9.11,14 


Device Number 


37^ 


DISASSEMBLE 


r ■ 

4 


Disploy initio 1 


1 


Display^ memory 


7 


DJsploy regisre^ 


M^.9.10 


Dollar fii^n 


3 


ENABLE VfrhJolZero Page 


5 


EOF 


7 


Errorindicator 


2 


Exompleprogrom 


11 


Execoteo program 


3^ 


ExittaBASIC-X 


10 


Expansior Board with VICMON 


1 


Expansion RAM with V CMON 


1.12 


f oiflts in program 


4A1U2 


FILLiYiemory 


5 


GO 


3,5.8 


Hex code, display 


7 


Highlim 


8 


HUNT 


6 


Inilial dispoy 


1 


INTERPRET 


6 


Iterotioni, number of 


4 


JUMP 


7 


Ksfrnl 


5 


LOAD 


7 


Load file 


7 


Logical fau t& 


4,6 


Lowlim 


e 


Machine code 


1,3 



MEMORY 


7 




Memory change 


8 




Memory Expansion Board, 






VCMONwitii 


1 


5 


Memory, FILL 


5 


r 


NUMBER 


8 




Number oliterotions 


4 




Offaet 


3,8 




Op Code 


3,4 




Operand ■ 


3A8 




PaHern 


5 


' 


Program Counter 


5,9,9 




Program Execution 


3,5 JO 


r 


Program file 


7 


s 


Programmer'5Aid,VICMONwith 1 


\ 


Prom pi 


2 


i 


Question marV 


2 




QUICK TRACE 


2.a 




Quote, single 

RAM. bad location 


6 




8 




RAM, exponsion. with V CMON 


1 




Ref 


3 




Reference reodJng 


1 




REGSItRS 


9 




Reqister^. disploy 
Relocote 


1,4.5,9,10 




10 




REMOVE BREAKPOINT 


9 




RETURN 05 terminotor 


2 




Relurn to BASIC 


4fi 




ROM, ottemptto modify 


B 




RTS 


67 




Runaway 


i 




SAVE 


7.9 




Scrol ing 


447 




Singlequote 


6 




Single stepping 


7,10 




Stack 


7 




Starting the VICMON system 


1 




STOP key 


4A?,8,!0 




Strings 


6 




Sub routine 


7,10 




Super Exponder, V CMON wiih 


1 




SYS 


1 




Tape Files 


7 




TRANSF^ft 


8.10 




Virtua Zero Page 


5.6.8,13 




WALK 


7,a,10 




Wrop around 


8 




Word toble 


8 


■ 


X and STOP keys 


a 




X-EXIT TO BASIC 


10 




Zero Page 


5,6,8,15 





15 



SUMMARY OF COMMANDS 



CoTTirJ^and 
Assemble 

BrGokpoJnl 

Enable Virtuol Zero Poge 

Fill MemofY 

Go 

Hunt 
Inter prof 

Jump Jo subroirfne 

Lood 

Memory 

Number 
Qukl< Trace 

Remove Breakpoints 

5ove 

Transfer 

Walk 

Eitiiro BASIC 



Synftrrir f'oge 

A ( odd r],( opcode L I opOfOnd) ,>., .---t 3 

B (oddr) - , 3 

or B (nddr|,n 

D (oddr) 4 

or D (oddr).faddr) 

E [oddr} 5 

F |ciddrj,laddr),(val'jej •..•^, 5 

G 5 

or G (oddr} 

H [addrl.faddri^fdofa) ., fi 

I IqddrMadd'l 6 

or i |addr| 

J -.,. 7 

L "filBnome",fdcv! -,- 7 

W Mdr|,(oddr) 7 

or M ^addr] 

N (oddr). (oddr] ^^offsplLflowlim^luplimj.W 6 

-,, 8 



Q 

R 

RB 



or Q [oddr) 



_ 9 

9 

S ■■filBnDmG",ldev[,Caddrj.laddT) _ 9 

T (oddrj,toddr),|oddp] 10 

W ,..10 



or W (oddrj 



,10 



AlUommondsencept JafBtermirtOledandexect^tionjsbegunby pfessJfwj'he RETURN key. 

The poro meters in ttie command fomiol^ ore repfcsenled os foiJowsr 

(oddrj o two byte hex address, e g. 040D 

dev] a single byto hoK device number, eg, 08 

opcode! o valid 65C2 assembly mtieunKJnirr pg LDA 

operond) a vol id operood loi'theprBcsdmg mstiuction, e.g ~$01 

(value) a single byte hen walue^ e.g FF 

(data) o string of literal data enclosed i^qtrOlesorhex values. Successive items are separarod 

with commas, 

(fef) atv^obyiG tvesi address, eg- 2G00 

(of^) o Iwo byte Kev oHsei vduc, e.g. 3000 

To Storf monitor, type SYS2'1576 or 5YS^4096 



f E commodore 

^ COMPUTER